home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9256 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  97 lines

  1. Path: news.telepac.pt!usenet
  2. From: vortex@telepac.pt (VORTEX)
  3. Newsgroups: comp.lang.c
  4. Subject: CRC READING ERROR  HELP PLEASE!!!!
  5. Date: Sat, 09 Mar 1996 05:38:36 GMT
  6. Organization: telepac
  7. Message-ID: <4hqk0u$2e8@vivaldi.telepac.pt>
  8. Reply-To: vortex@telepac.pt
  9. NNTP-Posting-Host: por1_p7.telepac.pt
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12.  
  13. Can anyone help inserting a routine in this program that make a hook
  14. to int24h and return the fail code everytime...
  15. The intension is if it occurs a CRC error i put my own message on
  16. screen instead of DOS msg.
  17.  
  18. Thanks in advance
  19.  
  20.  
  21. //
  22. //This reading 8 files named SOURCE.1 to SOURCE.8
  23. //& join them together in a final D:\FINAL.EXE
  24. //
  25.  
  26.  
  27. #include <stdio.h>
  28. #include <fcntl.h>
  29. #include <sys\stat.h>
  30. #include <io.h>
  31. #include <stdlib.h>
  32. #include <dos.h>
  33. #include <string.h>
  34.  
  35. #define READ_BYTES (62L * 1024L)
  36.  
  37. void main(void)
  38. {
  39.     char buf[READ_BYTES+1];
  40.     char file_on_disk[16]="source.";
  41.     char filename[129]="d:\\final.exe";
  42.     int f_src, f_dst;
  43.     unsigned int bytes;
  44.     int i, num_disks=8;
  45.     char s1[20],s2[4];
  46.  
  47.  
  48. // Check if destination file exists. If so TRUNCAT to 0 bytes
  49. //                                     If no CREAT a new one with 0 bytes
  50.  
  51.      if((f_dst= creat(filename, S_IWRITE  )) == -1) {
  52.        printf("Cannot open destination file : %s\n",filename);
  53.        exit(1);
  54.      }
  55.  
  56.      close(f_dst);
  57.  
  58.     _dos_creat(filename, O_APPEND, &f_dst);
  59.  
  60.  
  61.    for (i=0;i<num_disks;i++) {
  62.  
  63.     strcpy(s1,file_on_disk);
  64.      itoa(i+1,s2,10);                 // Converts an Integer to a String
  65.       strcat(s1,s2);
  66.  
  67.     if((f_src = open(s1, O_RDONLY | O_BINARY)) == -1) {
  68.      printf("Cannot open source file: %s\n", s1);
  69.       exit(1);
  70.     }
  71.  
  72.  
  73.     printf("Reading : %s\n",s1);
  74.  
  75.  
  76.  
  77. // This is where all the work is done (read from source file
  78. // and write to destination, until done)
  79.  
  80.     while (_dos_read(f_src, buf, READ_BYTES, &bytes)==0) {
  81.       write(f_dst, buf, bytes);
  82.         if (bytes < READ_BYTES) break;
  83.     }
  84.  
  85.      _dos_close(f_src);
  86.  
  87.    }
  88.  
  89. // Close destination file
  90.  
  91.     close(f_dst);
  92.  
  93. }
  94.  
  95.  
  96.  
  97.